﻿/// <reference path="BaseTextNode.js" />
/// <reference path="TreeNodeType.js" />

var $HyperLinkNode = TA.Turbo.Controls.HyperLinkNode = function HyperLinkNode()
{
	this.BaseTextNode();
}
$HyperLinkNode.Inherit($BaseTextNode);

var ____a;
if (____a)
{
	$HyperLinkNode.prototype = new $BaseTextNode();
	$HyperLinkNode.prototype.BaseTextNode = new $BaseTextNode();
}

$HyperLinkNode.prototype.Href = null;
$HyperLinkNode.prototype.OnClick = null;
$HyperLinkNode.prototype.Target = null;


$HyperLinkNode.prototype.get_Type = function get_Type()
{
	return TreeNodeType.HyperLink;
}

$HyperLinkNode.prototype.SerializeContents = function SerializeContents(jw)
{
	this.BaseTextNode.SerializeContents.call(this, jw);

	if (this.Href != null)
		jw.Property("H", this.Href);
	if (this.OnClick != null)
		jw.Property("O", this.OnClick);
	if (this.Target != null)
		jw.Property("Ta", this.Target);
}
$HyperLinkNode.prototype.DeserializeContent = function DeserializeContent(propShortName, value)
{
	switch (propShortName)
	{
		case "H": this.Href = value; break;
		case "O": this.OnClick = value; break;
		case "Ta": this.Target = value; break;
		default: this.BaseTextNode.DeserializeContent.call(this, propShortName, value);
	}
}

$HyperLinkNode.prototype._CreateContent = function _CreateContent()
{
	var anchor = document.createElement("A");
	if (this.Href != null)
		anchor.href = this.Href;
	if (this.OnClick != null)
	{
		var c = this.OnClick;
		anchor.AddEvent("click", function(event) { eval(c); });
	}
	if (this.Target != null)
	{
		anchor.target = this.Target;
	}
	anchor.innerHTML = this.Text.HTMLEncode();

	this.get_DivContent().appendChild(anchor);
}

